import Mock from 'mockjs2'
import {builder, getQueryParameters} from "@/mock/util";


const reportList = (options) => {
	console.log('report mock: reportList')
	console.log(options)
const result = builder(
	{
		"total":6,
		"current":1,
		"size":10,
		"pages":1,
		"data":[
			{"id":16,"name":"test1","remark":"","createdAt":"2022-02-28 10:27:52","updatedAt":"2022-02-28 10:27:52"},
			{"id":14,"name":"test2","remark":"发展报表","createdAt":"2021-06-25 14:28:01","updatedAt":"2021-06-25 14:28:04"},
			{"id":2,"name":"shared1","remark":"发展报表","shared":true,"createdAt":"2021-06-25 14:28:01","updatedAt":"2021-06-25 14:28:03"},
			{"id":3,"name":"shared2","remark":"发展报表","shared":true,"createdAt":"2021-06-25 14:28:01","updatedAt":"2021-06-25 14:28:03"},
			{"id":4,"name":"shared3","remark":"发展报表","shared":true,"createdAt":"2021-06-25 14:28:01","updatedAt":"2021-06-25 14:28:03"},
			{"id":5,"name":"发展报表","remark":"发展报表","createdAt":"2021-06-25 14:28:01","updatedAt":"2021-06-25 14:28:03"}]})
	console.log(result)
	return result
}

const reportUsers = (options) => {
	console.log('report mock: reportUsers')
	console.log(options)
	return builder([{"id":"2c9280847af5ca5f017af60f10680000","username":"admin2","email":"qqq@qq.com","phone":"18888888888","active":0,"createdAt":"2021-07-30 14:17:00","updatedAt":"2021-08-16 16:51:07","roleIds":[2],"remark":""},{"id":"2c9280847af5ca5f017bddb56ad00007","username":"正式服-测试人员","email":"","phone":"18888888888","active":1,"createdAt":"2021-09-13 13:50:59","updatedAt":"2022-02-25 14:18:24","roleIds":[29],"remark":"edit"}])
}

const getSharedInfo = (options) => {
	console.log('report mock: getSharedInfo')
	console.log(options)
	return builder({key:"testKey"})
}


const addSharedKey = (options) => {
	console.log('report mock: addSharedKey')
	console.log(options)
	return builder({key:"testKeyAdd"})
}

const deleteSharedKey = (options) => {
	console.log('report mock: deleteSharedKey')
	console.log(options)
	return builder({key:"testKeyDelete"})
}

const followingStatus = (options) => {
	return builder(true)
}


// Mock.mock(/^.*?\/smartreportservice\/report\?.*?/ , 'get', reportList)
// Mock.mock(/^.*?\/smartreportservice\/report\/\w+\/share\/users.*?/ , 'get', reportUsers)
Mock.mock(/^.*?\/smartreportservice\/report\/.*\/key.*?/ , 'get', getSharedInfo)
Mock.mock(/^.*?\/smartreportservice\/report\/.*\/key.*?/ , 'post', addSharedKey)
Mock.mock(/^.*?\/smartreportservice\/report\/.*\/key\/.*?/  , 'delete', deleteSharedKey)
Mock.mock(/^.*?\/smartreportservice\/report\/follow\/[0-9]+.*?/, 'get', followingStatus)
